//
//  ZFWeatherManager.swift
//  map
//
//  Created by fyzq on 2024/1/30.
//

import UIKit
import QWeather
import RxSwift
class ZFWeatherManager: NSObject {
    private var appKey = "c5912dcefdb040c0aa1751aabcbcf4c8"
    private var publicID = "HE2401301723481495"
    
    static let shared = ZFWeatherManager()
    
    func defaultConfig(){

        
    }
    
    
    static func getDayWeather()->Observable<Now>{
        
        return Observable.create { observer in
            let qWeather = AllWeatherInquieirs.sharedInstance()!
            qWeather.publicID = shared.publicID
            qWeather.appKey = shared.appKey
            qWeather.appType = APP_TYPE.DEV
            qWeather.weather(withInquireType:INQUIRE_TYPE.WEATHER_NOW, withSuccess: { data in
                let res = data as! WeatherBaseClass
                if res.code == "200" {
                    observer.onNext(res.now)
                }else {
                    observer.onError(NSError(domain: "错误", code: 300))
                }
                observer.onCompleted()
            }, faileureForError: { error in
                observer.onError(error!)
                observer.onCompleted()
            })
            return Disposables.create()
        }
    }
    
    

    
}
